#!/bin/bash

DIR=$(pwd)
list=(
"mount_dyzio"				"sshfs kamil@www.dyzio.pl:/ $DIR/dyzio/"
"mount_dyzio_4004" 			"sshfs -p4004 kamil@www.dyzio.pl:/ $DIR/dyzio/"
"mount_dyzio_mojdysk" 		"sshfs -p22 kamil@www.dyzio.pl:/mnt/sdc4/kamil/ $DIR/dyzio_mojdysk/"
"mount_dyzio_mojdysk_4004" 	"sshfs -p4004 kamil@www.dyzio.pl:/mnt/sdc4/kamil/ $DIR/dyzio_mojdysk/"
"mount_leonidas_dom" 		"sshfs kamil@192.168.20.10:/ $DIR/leonidas/"
"mount_leonidas_pw" 		"sshfs kamil@10.8.3.184:/ $DIR/leonidas/" 
"mount_ustropecet" 			"sshfs kcukrows@10.3.2.42:/ $DIR/ustropecet/"
"mount_wujek" 				"sshfs -p 10022 kamil@194.29.178.8:/ $DIR/wujek/"

"unmount_dyzio" 			"fusermount -u $DIR/dyzio/"
"unmount_dyzio_mojdysk" 	"fusermount -u $DIR/dyzio_mojdysk/"
"unmount_leonidas" 			"fusermount -u $DIR/leonidas/"
"unmount_studia_ustropecet" "fusermount -u $DIR/studia/"
"unmount_ustropecet" 		"fusermount -u $DIR/ustropecet/"
"unmount_wujek" 			"fusermount -u $DIR/wujek/"
)
dirs=( "dyzio" "dyzio_mojdysk" "leonidas" "studia" "ustropecet" "wujek" )

case "$1" in
clean)
	for i in $(seq 0 $[${#dirs[@]}-1]); do 
		rmdir ${dirs[$i]}
	done
	bool=0
	for i in $(seq 0 $[${#list[@]}-1]); do
		test $bool -le 0 && { bool=1; name=${list[$i]}; continue; }
		test $bool -le 1 && { bool=0; exec=${list[$i]}; }
	
		rm $DIR/$name.desktop
	done
	;;
create)
	for i in $(seq 0 $[${#dirs[@]}-1]); do 
		mkdir $DIR/${dirs[$i]}
	done
	bool=0
	for i in $(seq 0 $[${#list[@]}-1]); do
		test $bool -le 0 && { bool=1; name=${list[$i]}; continue; }
		test $bool -le 1 && { bool=0; exec=${list[$i]}; }
	
		echo -n "[Desktop Entry]
Version=1.0
Type=Application
Name=$name
Comment=
Exec=nohup $exec
Icon=
Path=
Terminal=true
StartupNotify=false" > $DIR/$name.desktop
		chmod +x $DIR/$name.desktop
	done
	;;
*)
	echo "$0 [create] [clean]"
	;;
esac
